#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
#include<vector>
#include<algorithm>
  



int main()
{
    int n = 0, x = 0;
    cin >> n;
    vector<int> v1;
    for (int i = 0; i < n; i++)
    {
        
        cin >> v1[i];
    }
    int sum = 0;
    //sum = min(sum + v1[0], sum + v1[1]);
    for (int i = 2; i < n; i++)
    {
        sum = min(sum + v1[i - 1], sum + v1[i - 2]);
    }
    return sum;
}